assume cs:code
code segment
start: mov ax,cs
	   mov ds,ax
	   mov si,offset setscreen
	   mov ax,0
	   mov es,ax
	   mov di,200h
	   mov cx,offset setscreenend-offset setscreen
	   cld
	   rep movsb
	   
	   mov ax,0
	   mov es,ax
	   cli
	   mov word ptr es:[7ch*4],200h
	   mov word ptr es:[7ch*4+2],0
	   sti
	   
	   mov ax,4c00h
	   int 21h
	   
setscreen:   jmp short set
	  table dw offset clear - offset setscreen + 202h
			dw offset front - offset setscreen + 202h
			dw offset back - offset setscreen + 202h
			dw offset up - offset setscreen + 202h
		   
set:push bx
	cmp ah,3
	ja sret
	mov bl,ah
	mov bh,0
	add bx,bx
	call word ptr table[bx]
sret: pop bx
	  iret
clear: push bx
	   push cx
	   push es
	   mov bx,0b800h
	   mov es,bx
	   mov bx,0
	   mov cx,2000
clears:mov byte ptr es:[bx],' '
	   add bx,2
	   loop clears
	   pop es
	   pop cx
	   pop bx
	   ret
front: push bx
	   push cx
	   push es
	   mov bx,0b800h
	   mov es,bx
	   mov bx,1
	   mov cx,2000
fronts:add byte ptr es:[bx],11111000b
	   or es:[bx],al
	   add bx,2
	   loop fronts
	   pop es
	   pop cx
	   pop bx
	   ret
back:  push bx
	   push cx
	   push es
	   mov cl,4
	   shl al,cl
	   mov bx,0b800h
	   mov es,bx
	   mov bx,1
	   mov cx,2000
backs: add byte ptr es:[bx],10001111b
	   or es:[bx],al
	   add bx,2
	   loop backs
	   pop es
	   pop cx
	   pop bx
	   ret
up:	   push cx
	   push si
	   push di
	   push es
	   push ds
	   mov si,0b800h
	   mov es,si
	   mov ds,si
	   mov si,160
	   mov di,0
	   cld
	   mov cx,24
ups:   push cx
	   mov cx,160
	   rep movsb
	   pop cx
	   loop ups
	   mov cx,80
	   mov si,0
ups1:  mov byte ptr [160*24+si],' '
	   add si,2
	   loop ups1
	   pop ds
	   pop es
	   pop di
	   pop si
	   pop cx
	   ret
setscreenend: nop

code ends
end start
